#ifndef COMMON_H
#define COMMON_H
#include <iostream>
#include <vector>
#include "math/box2d.h"

#define PURP_DARK_COLOR  0.31, 0.21, 0.40

//#define GREEN_COLOR 0.09, 0.74, 0.34
#define GREEN_COLOR 0.0, 0.9, 0.0

#define YELLOW_COLOR    0.91, 0.89, 0.12

#define BLACK_COLOR 0.0, 0.0, 0.0

#define RED_COLOR 1.0, 0.0, 0.0

#define BLUE_COLOR 0.0, 0.0, 1.0

#define WHITE_COLOR 1.0, 1.0, 1.0

#define   origin_dot     0x01
#define   straight_line  0x02
#define   bezal_line     0x04


typedef enum{
    RECORD =0,
    NO_RECORD =1,
}RECORDMAP_TYPE;

class GPSPoint {
public:
    float x_;   //现在按照全局
    float y_;
    float localx_;   //现在按照全局
    float localy_;
    float z_;
    double lon_;   //现在按照全局
    double lat_;
    float height_;
    float theta_; //现在统一为全局坐标车头与x轴的夹角
    float yaw_; //现在统一为全局坐标车头与x轴的夹角
    float v_;
    float acc_;
    float k_;
    float dk_;
    float ddk_;
    float s_;
    float theta_rate_;
    float t_;
    GPSPoint(){}

    GPSPoint(const double& x, const double& y, const double& z,const double& lon, const double& lat, const double& height, const double& theta)
    {
        this->x_ = x;
        this->y_ = y;
        this->z_ = z;
        this->lon_ = lon;
        this->lat_ = lat;
        this->height_ = height;
        this->theta_ = theta;
    }
};


typedef struct{
    int index = -1;
    double lon;
    double lat;
    double mouse_x;
    double mouse_y;
    double local_x;
    double local_y;
    double global_x;
    double global_y;
    float yaw;
    float theta;
    float speed_limit = 5;
    int lane_num = 5;
    int lane_index = 2;
    int tracing_mode = 4;
    float left_bound = -4;
    float right_bound = 4;
    int road_index = 0;
    int location_state;
  //  std::string comment;
}STRoadPoint;

typedef struct{
    int index;
    ab::common::math::Box2d boundary_box;
    std::vector<STRoadPoint> gps_points;
    std::vector<STRoadPoint> wps_points;
    std::vector<STRoadPoint>  fence_points;
}SetofMapInfo;

typedef struct{
    int count;
    std::vector<SetofMapInfo> set_of_map_info;
}MapInfoPoints;

typedef struct{
    int count;
    std::vector<STRoadPoint> points;
}STRoadPoints;

typedef struct{
    double mouse_x;
    double mouse_y;
    bool has_checked = false;
    bool  has_pressed = false;
    bool has_double_pressed = false;
    bool has_captured = false;
    bool has_trigered = false;
    int select_index;
    STRoadPoint select_point;
}MouseStatus;

class PointType{
public:
    PointType(){};
    ~PointType(){};
public:
    double xp;
    double yp;
    double zp;

public:
    friend const PointType operator+(const PointType &p1, const PointType &p2){
        PointType p;
        p.xp = p1.xp+p2.xp;
        p.yp = p1.yp+p2.yp;
        p.zp = p1.zp+p2.zp;
        return p;
    }
    friend const PointType operator-(const PointType &p1, const PointType &p2){
        PointType p;
        p.xp = p1.xp-p2.xp;
        p.yp = p1.yp-p2.yp;
        p.zp = p1.zp-p2.zp;
        return p;
    }
    friend inline const PointType operator*(const PointType &p1,double f1)
    {
        PointType p;
        p.xp = p1.xp*f1;
        p.yp = p1.yp*f1;
        p.zp = p1.zp*f1;
        return p;
    }

};

typedef struct{
    double xp;
    double yp;
    double zp;
}point_type_t;

typedef struct finder_t
{
    finder_t(STRoadPoint &n) : point(n) {}
    bool operator()(STRoadPoint another)
    {
      return (((point.mouse_x == another.mouse_x))&&(point.mouse_y == another.mouse_y));
    }
    STRoadPoint point;
}finder_t;


class ConfigInfo{
public:
    ConfigInfo(){}
    ~ConfigInfo(){}
public:
    double basic_lon_;
    double basic_lat_;
    int record_map_;
    std::string speedunit_;
    std::string yawunit_;
    float lane_width_;
};


#endif
